﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HF.Business.OA;


public partial class BaseUserControls_cpMessage : System.Web.UI.UserControl
{
    string UserId = "";
    DataTable mainDt;
    protected void Page_Load(object sender, EventArgs e)
    {

        UserId = this.Page.User.Identity.Name;
        InitData();
      

    }
    public void BuildNoRecords(GridView gridView, DataTable dt)
    {
        try
        {
            if (dt.Rows.Count == 0)
            {
                dt.Rows.Add(dt.NewRow());
                gridView.DataSource = dt;
                gridView.DataBind();
                int columnCount = gridView.Rows[0].Cells.Count;
                gridView.Rows[0].Cells.Clear();
                gridView.Rows[0].Cells.Add(new TableCell());
                gridView.Rows[0].Cells[0].ColumnSpan = columnCount;
                gridView.Rows[0].Cells[0].Text = "没有数据.";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    private void InitData()
    {
        mainDt = OA_MESSAGE.GetOA_MESSAGE(20);
        gvMessage.DataSource = mainDt;
        gvMessage.DataBind();
        BuildNoRecords(gvMessage, mainDt);
    }
}
